package types

// DeviceProfile is structure to store in configMap. These types would be consumed by mappers to marshal / unmarshal the device profile json
type DeviceProfile struct {
	// DeviceInstances is used to store list of all devices.
	DeviceInstances []*DeviceInstance `json:"deviceInstances,omitempty"`
	// DeviceModels is used to store list of all DeviceModels referenced by DeviceInstances
	DeviceModels []*DeviceModel `json:"deviceModels,omitempty"`
	// Protocols is list of all protocols used by DeviceInstances
	Protocols []*Protocol `json:"protocols,omitempty"`
	// PropertyVisitors is list of all PropertyVisitors in DeviceModels
	PropertyVisitors []*PropertyVisitor `json:"propertyVisitors,omitempty"`
}

// DeviceInstance is structure to store device in deviceProfile.json in configmap
type DeviceInstance struct {
	// ID is deviceInstance ID
	ID string `json:"id,omitempty"`
	// Name is deviceInstance name
	Name string `json:"name,omitempty"`
	// Protocol is deviceInstance protocol name. It is generated by deviceController
	Protocol string `json:"protocol,omitempty"`
	// Model is deviceInstance model name
	Model string `json:"model,omitempty"`
}

// DeviceModel is structure to store deviceModel in deviceProfile.json in configmap
type DeviceModel struct {
	// Name is DeviceModel name
	Name string `json:"name,omitempty"`
	// Description is DeviceModel description
	Description string `json:"description,omitempty"`
	// Properties is list of DeviceModel properties
	Properties []*Property `json:"properties,omitempty"`
}

// Property is structure to store deviceModel property
type Property struct {
	// Name is Property name
	Name string `json:"name,omitempty"`
	// DataType is property dataType
	DataType string `json:"dataType,omitempty"`
	// Description is property description
	Description string `json:"description,omitempty"`
	// AccessMode is property accessMode
	AccessMode string `json:"accessMode,omitempty"`
	// DefaultValue is property defaultValue
	DefaultValue interface{} `json:"defaultValue,omitempty"`
	// Minimum is property minimum value in case of int
	Minimum int64 `json:"minimum,omitempty"`
	// Maximum is property maximum value in case of int
	Maximum int64 `json:"maximum,omitempty"`
	// Unit is unit of measurement
	Unit string `json:"unit,omitempty"`
}

// Protocol is structure to store protocol in deviceProfile.json in configmap
type Protocol struct {
	// Name is protocol name
	Name string `json:"name,omitempty"`
	// Protocol is protocol name defined in deviceInstance. It is generated by deviceController
	Protocol string `json:"protocol,omitempty"`
	// ProtocolConfig is protocol config
	ProtocolConfig interface{} `json:"protocol_config"`
}

// PropertyVisitor is structure to store propertyVisitor in deviceProfile.json in configmap
type PropertyVisitor struct {
	// Name is propertyVisitor name
	Name string `json:"name,omitempty"`
	// PropertyName is name of property it is mapped to
	PropertyName string `json:"propertyName,omitempty"`
	// ModelName is deviceModel name
	ModelName string `json:"modelName,omitempty"`
	// Protocol is protocol of propertyVisitor
	Protocol string `json:"protocol,omitempty"`
	// VisitorConfig is property visitor configuration
	VisitorConfig interface{} `json:"visitorConfig,omitempty"`
}
